import csv
from scapy.all import *


def solve(pkt0):
    a1 = pkt0['Ethernet'].dst
    a2 = pkt0['Ethernet'].src
    a3 = pkt0['Ethernet'].type

    b1 = pkt0['IP'].version
    b2 = pkt0['IP'].ihl
    b3 = pkt0['IP'].tos
    b4 = pkt0['IP'].len
    b5 = pkt0['IP'].id
    b6 = pkt0['IP'].flags
    b7 = pkt0['IP'].frag
    b8 = pkt0['IP'].ttl
    b9 = pkt0['IP'].proto
    b10 = pkt0['IP'].chksum
    b11 = pkt0['IP'].src
    c11 = 0
    if b11 == "192.168.230.128":
        c11 = 1
        print("yes")
    else:
        c11 = 0
    b12 = pkt0['IP'].dst
    c1 = pkt0['TCP'].sport
    c2 = pkt0['TCP'].dport
    c3 = pkt0['TCP'].seq
    c4 = pkt0['TCP'].ack
    c5 = pkt0['TCP'].dataofs
    c6 = pkt0['TCP'].reserved
    c7 = pkt0['TCP'].flags
    c8 = pkt0['TCP'].window
    c9 = pkt0['TCP'].chksum
    c10 = pkt0['TCP'].urgptr

    rows = [a1, a2, a3, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11]

    # with open('test.csv', 'a+', newline='') as f:
    #     fcsv = csv.writer(f)
    #     fcsv.writerow(rows)


pkts = rdpcap("test.pcap")
for pkt in pkts:
    solve(pkt)
